<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/static/admin/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="/static/admin/lib/font-awesome-4.7.0/css/font-awesome.min.css" media="all">
    <link rel="stylesheet" href="/static/admin/css/public.css" media="all">
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">
        <form class="layui-form">
            <div class="layui-form-item">

                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">管理员名称</label>
                        <div class="layui-input-inline">
                            <input type="text" name="back_name" lay-verify="required" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">所属角色</label>
                        <div class="layui-input-inline">
                            <select name="role_id" lay-verify="required" lay-search="">
                                {if !empty($roles) }
                                    {volist name="$roles" id="rs"}
                                        <option value="{$rs.role_id}">{$rs.role_name}</option>
                                    {/volist}
                                {/if}

                            </select>
                        </div>
                    </div>
                </div>

                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">用户名</label>
                        <div class="layui-input-inline">
                            <input type="text" name="username" autocomplete="off" class="layui-input" >
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label for="" class="layui-form-label">密码</label>
                        <div class="layui-input-block">
                            <input type="password" name="password"  class="layui-input">
                        </div>
                    </div>
                </div>


                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">手机号</label>
                        <div class="layui-input-inline">
                            <input type="text" name="back_phone"  value="" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">邮箱</label>
                        <div class="layui-input-block">
                            <input type="text" name="back_email"  value="" class="layui-input">
                        </div>
                    </div>
                </div>

                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" type="button" lay-submit="" lay-filter="zz_add">立即提交</button>
                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    </div>
                </div>
        </form>
    </div>
</div>

<script src="/static/admin/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script src="/static/admin/js/lay-config.js?v=1.0.4" charset="utf-8"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
    layui.use(['form','iconPickerFa'], function () {
        var form = layui.form
            , layer = layui.layer
            , $ = layui.jquery;


        //监听提交
        form.on('submit(zz_add)', function (data) {
            data = data.field;
            $.ajax({
                url : '/back/back/add',
                data :data,
                type:'POST',
                success:function(res){
                    if(res.code == 1){
                        layer.msg(res.msg,{icon:1,time:2000},function(){
                            var index = parent.layer.getFrameIndex(window.name);
                            parent.location.reload();
                            parent.layer.close(index);
                        });
                    }else{
                        layer.msg(res.msg,{icon:2});
                    }

                }
            });
            return false;
        });



    });
</script>

</body>
</html>